<!-- 评论组件 -->
<template>
    <div class="container">
        <!-- 发表评论 -->
        <div class="releaseComment">
            <el-input v-model="commentCentent" maxlength="100" placeholder="评论千万条，友善第一条" type="textarea" show-word-limit />
            <el-button type="danger" plain>评论</el-button>
        </div>

        <!-- 最热评论 -->
        <div class="hot">
            <!-- 最热评论 -->
            <div class="title">最热评论</div>
            <div class="item" v-for="item in hotComment" :key="item.commentId">
                <!-- 评论人 -->
                <div class="commentPerson">
                    <!-- 头像 -->
                    <div class="avatar">
                        <img :src="item.user.avatarUrl" alt="加载中...">
                    </div>
                    <!-- 头像旁边的信息 -->
                    <div class="userInfo">
                        <div class="nickname">{{ item.user.nickname }}</div>
                        <div class="date">{{ item.timeStr }}</div>
                    </div>
                </div>
                <!-- 评论内容 -->
                <div class="content">{{ item.content }}</div>
            </div>
        </div>

        <!-- 最新评论 -->
        <div class="latest">
            <div class="title">最新评论</div>
            <div class="item" v-for="item in newComment" :key="item.commentId">
                <!-- 评论人 -->
                <div class="commentPerson">
                    <!-- 头像 -->
                    <div class="avatar">
                        <img :src="item.user.avatarUrl" alt="加载中...">
                    </div>
                    <!-- 头像旁边的信息 -->
                    <div class="userInfo">
                        <div class="nickname">{{ item.user.nickname }}</div>
                        <div class="date">{{ item.timeStr }}</div>
                    </div>
                </div>
                <!-- 评论内容 -->
                <div class="content">{{ item.content }}</div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { playlistComment } from '../../api/comment/comment'
import { defineProps } from "vue";

const { id } = defineProps(['id'])

// 评论内容
let commentCentent = ref('')

// 热评
let hotComment: any = ref('')
// 评论
let newComment: any = ref('')

// 获取歌单评论

async function getComment() {
    let res: any = await playlistComment(id)
    console.log(res);
    hotComment.value = res.hotComments
    newComment.value = res.comments
}
getComment()







</script>

<style lang="less" scoped>
.container {
    width: 100%;
    height: auto;
    margin-top: 1rem;

    .releaseComment {
        width: 96%;
        height: 5rem;

        .el-button {
            float: right;
            margin-top: 0.5rem;
        }

        .total {
            color: #666;
            font-size: 14px;
            padding-left: 0.1rem;
        }
    }

    .hot,
    .latest {
        width: 100%;

        .title {
            font-size: 18px;
            font-weight: 600;
            margin-top: 1rem;
        }

        .item {
            display: flex;
            align-items: center;
            margin: 1rem 0;
            width: 96%;
            height: 5rem;
            border-bottom: 1px solid #ccc;
            position: relative;

            .commentPerson {
                display: flex;
                align-items: center;
                width: 10rem;
                cursor: pointer;
                z-index: 1;
                margin-right: 2rem;

                .avatar {
                    height: 3rem;
                    width: 3rem;
                    margin: 0.5rem;

                    img {
                        width: 100%;
                        height: 100%;
                        border-radius: 50%;
                    }
                }

                .nickname {
                    width: 5rem;
                    font-size: 14px;
                }

                .date {
                    font-size: 13px;
                    color: #666;
                }
            }

            .content {
                margin-left: 50px;
                font-size: 12px;
                width: 100%;
            }

            .deletable {
                position: absolute;
                right: 0;
                font-size: 13px;
                cursor: pointer;
                padding: 0.5rem;

                &:hover {
                    color: #e64545;
                }
            }
        }
    }
}
</style>